package ndkclient

import "C"
import (
	"fmt"
	"time"

	"gitee.com/chen_wei_jing/kinx/zlog"
	"gitee.com/chen_wei_jing/kinx/znet"
)

//export ConnectServer
func ConnectServer() uint64 {
	client := znet.NewKcpClient("120.26.183.54", 7777, 30)
	client.StartHeartBeat(2 * time.Second)

	connId, _ := client.Connect(10)

	zlog.Ins().DebugF("client exit!")

	return connId
}

//export SetLogDir
func SetLogDir(dir string) uint64 {
	fmt.Println("设置日志目录:", dir)
	return 0
}

type RecvMsgFn func(int, int) int

var fn RecvMsgFn = nil

//export SendMsg
func SendMsg(msgId uint32, data []byte) int64 {
	fmt.Println("发送数据", msgId, string(data))
	return 0
}

//export RecvMsg
func RecvMsg() {
	if fn != nil {
		fn(1, 1)
	}
}

func main() {}
